package leecode

func minOperations2869(nums []int, k int) int {
	hashMap := make(map[int]bool, k)
	for i := 1; i <= k; i++ {
		hashMap[i] = true
	}
	var result int
	for i := len(nums) - 1; i >= 0; i-- {
		if _, ok := hashMap[nums[i]]; ok {
			delete(hashMap, nums[i])
		}
		result++
		if len(hashMap) == 0 {
			break
		}
	}
	return result
}
